/**
 * <copyright>
 * </copyright>
 *
 */
package de.sabram.upb.specs.ptg.impl;

import de.sabram.upb.specs.ptg.Argument;
import de.sabram.upb.specs.ptg.Insertion;
import de.sabram.upb.specs.ptg.PtgPackage;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Argument</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link de.sabram.upb.specs.ptg.impl.ArgumentImpl#getInsertion <em>Insertion</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ArgumentImpl extends MinimalEObjectImpl.Container implements Argument
{
  /**
   * The cached value of the '{@link #getInsertion() <em>Insertion</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getInsertion()
   * @generated
   * @ordered
   */
  protected Insertion insertion;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected ArgumentImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return PtgPackage.Literals.ARGUMENT;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Insertion getInsertion()
  {
    return insertion;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetInsertion(Insertion newInsertion, NotificationChain msgs)
  {
    Insertion oldInsertion = insertion;
    insertion = newInsertion;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, PtgPackage.ARGUMENT__INSERTION, oldInsertion, newInsertion);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setInsertion(Insertion newInsertion)
  {
    if (newInsertion != insertion)
    {
      NotificationChain msgs = null;
      if (insertion != null)
        msgs = ((InternalEObject)insertion).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - PtgPackage.ARGUMENT__INSERTION, null, msgs);
      if (newInsertion != null)
        msgs = ((InternalEObject)newInsertion).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - PtgPackage.ARGUMENT__INSERTION, null, msgs);
      msgs = basicSetInsertion(newInsertion, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, PtgPackage.ARGUMENT__INSERTION, newInsertion, newInsertion));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case PtgPackage.ARGUMENT__INSERTION:
        return basicSetInsertion(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case PtgPackage.ARGUMENT__INSERTION:
        return getInsertion();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case PtgPackage.ARGUMENT__INSERTION:
        setInsertion((Insertion)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case PtgPackage.ARGUMENT__INSERTION:
        setInsertion((Insertion)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case PtgPackage.ARGUMENT__INSERTION:
        return insertion != null;
    }
    return super.eIsSet(featureID);
  }

} //ArgumentImpl
